package com.xingongchang.baolebei.protocol;

import org.json.JSONException;
import org.json.JSONObject;

import com.external.activeandroid.Model;
import com.external.activeandroid.annotation.Column;
import com.external.activeandroid.annotation.Table;
import com.insthub.BeeFramework.view.SlideView;

@Table(name = "USER_TOPIC")
public class LETTER extends Model {
	
	public SlideView slideView;

	@Column(name = "letterid")
	public int letterid;

	@Column(name = "creaton")
	public String creaton;

	@Column(name = "content")
	public String content;

	@Column(name = "sendname")
	public String sendname;
	
	@Column(name = "userphoto")
	public String userphoto;

	@Column(name = "is_send")
	public int is_send;
	
	@Column(name = "friendName")
	public String friendName;

	@Column(name = "friend")
	public int friend;

	@Column(name = "is_status")
	public int is_status;

	@Column(name = "receiver")
	public int receiver;
	
	@Column(name = "sender")
	public int sender;
	
	@Column(name = "sex")
	public int sex;

	public static LETTER fromJson(JSONObject jsonObject)
			throws JSONException {
		if (null == jsonObject) {
			return null;
		}
		LETTER localItem = new LETTER();

		localItem.content = jsonObject.optString("content");
		localItem.sendname = jsonObject.optString("sendname");
		localItem.userphoto = jsonObject.optString("userphoto");
		localItem.is_send = jsonObject.optInt("is_send");
		localItem.creaton = jsonObject.optString("creaton");
		localItem.friend = jsonObject.optInt("friend");
		localItem.friendName = jsonObject.optString("friendName");
		localItem.is_status = jsonObject.optInt("is_status");
		localItem.receiver = jsonObject.optInt("receiver");
		localItem.sender = jsonObject.optInt("sender");
		localItem.sex = jsonObject.optInt("sex");
		localItem.letterid = jsonObject.optInt("id");

		return localItem;
	}

}